//
//  AbstractFactory.m
//  AbstractFactory
//
//  Created by flannery on 2018/12/17.
//  Copyright © 2018年 flannery. All rights reserved.
//

#import "AbstractFactory.h"

@implementation AbstractFactory
- (id<Color>)getColor:(NSString *)colorType{
    return nil; //父类
}

- (id<Shape>)getShape:(NSString *)shapeType{
    return nil; //父类
}
@end


@implementation ShapeFactory

- (id<Color>)getColor:(NSString *)colorType{
    return nil;
}

- (id<Shape>)getShape:(NSString *)shapeType{
    if(shapeType == nil) {
        return nil;
    }
    if([shapeType isEqualToString:@"CIRCLE"]) {
        return Circle.new;
    } else if([shapeType isEqualToString:@"RECTANGLE"]) {
        return Rectangle.new;
    } else if([shapeType isEqualToString:@"SQUARE"]) {
        return Square.new;
    }
    return nil;
}

@end

@implementation ColorFactory

- (id<Color>)getColor:(NSString *)colorType{
    if(colorType == nil) {
        return nil;
    }
    if([colorType isEqualToString:@"RED"]) {
        return Red.new;
    } else if([colorType isEqualToString:@"GREEN"]) {
        return Green.new;
    } else if([colorType isEqualToString:@"BLUE"]) {
        return Blue.new;
    }
    return nil;
}

- (id<Shape>)getShape:(NSString *)shapeType{
    return  nil;
}

@end
